home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94b.txt / 000000_icon-group-sender _Thu Aug 18 20:53:54 1994.msg next >
Internet Message Format  |  1995-02-09  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Fri, 19 Aug 1994 05:34:01 MST
  2. To: icon-group-l@cs.arizona.edu
  3. Date: 18 Aug 1994 20:53:54 -0700
  4. From: dave@cs.arizona.edu (Dave Schaumann)
  5. Message-Id: <331aci$gn3@baskerville.CS.Arizona.EDU>
  6. Organization: University of Arizona CS Department, Tucson AZ
  7. Sender: icon-group-request@cs.arizona.edu
  8. Subject: A small but (hopefully) helpful utility
  9. Errors-To: icon-group-errors@cs.arizona.edu
  10.  
  11.  
  12. Today, I decided to start my own personl library of icon routines.
  13. This change introduced a bug: all of a sudden, I was getting an
  14. "undeclared identifier" error on a call to one of my library
  15. routines.  After much checking of environment variables and
  16. directory contents, it occurred to me that my library code might
  17. just be shadowed by an "official" library file.
  18.  
  19. Sure enough, that was the case.  So I wrote the appended little
  20. program to check where a particular library file is.  Usage is
  21.  
  22.     wil <name list>
  23.  
  24. (wil == Which Icon Library).  Names should be as they appear in
  25. the link statement (ie, no trailing .u1, .u2, or .icn).  The
  26. program will then print out where it finds each name (including
  27. multiple occurrences.
  28.  
  29. Bugs: this will break on file names with white spaces in them,
  30.     and is Un*x-specific.  Feel free to let me know if you
  31.     find any other problems...
  32.  
  33. $define SPACES  ' \t\n\r\v'
  34.  
  35. procedure search( path, names )
  36.   local f, name
  37.  
  38.   if path[-1] ~== "/" then path ||:= "/"
  39.   every name := !names do {
  40.     if f := open(path || name || ".u1", "r") then {
  41.       write( path || name )
  42.       close(f)
  43.       }
  44.     }
  45.   return
  46. end
  47.  
  48.  
  49. procedure main( args )
  50.   local IPATH
  51.  
  52.   IPATH := \getenv("IPATH") |
  53.     stop( "Can't read IPATH environment variable" )
  54.  
  55.   IPATH ? {
  56.     while tab(upto(~SPACES))  do
  57.       search( tab(many(~SPACES)), args )
  58.     }
  59.   search( ".", args )
  60. end
  61.  
  62.